<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 10171225
  Date: 2016/4/7
  Time: 10:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <base href="<%=basePath%>"/>
    <title>页头</title>

    <script type="text/javascript" language="JavaScript">
        $(document).ready(function(){
            $("#index").addClass("current");

            function toggleMenu(tag){
                $("#menu-top a").each(function(){
                    $(this).removeClass("current");
                });
                tag.addClass("current");
            }

            function loadMainContent(url) {
                obj=$.ajax({url:url,async:false});
                $("#main").html(obj.responseText);
            }

            $("#freeRegister").click(function () {
                $("#main").load("views/register.jsp");
            });

            $("#forgetPassword").click(function () {
                $("#main").load("views/forgetPassword.jsp");
            });

            $("#chartDes").click(function () {
                toggleMenu($(this));
                loadMainContent("page/chartDes");
            });

            $("#selectNumber").click(function () {
                toggleMenu($(this));
                loadMainContent("page/selectNumber");
            });

            $("#articles").click(function () {
                toggleMenu($(this));
                loadMainContent("page/articles");
            });

            $("#other").click(function () {
                toggleMenu($(this));
                loadMainContent("page/other");
            });

        });
    </script>

</head>
<body>
<div class="head">
    <c:choose>
        <c:when test="${sessionScope.containsKey('userName')}">
            <a href="user/personalHomePage"><c:out value="${sessionScope.get('userName')}"/></a>
            <a href="user/logout">退出</a><br/>
        </c:when>
        <c:otherwise>
            <form method="post" action="user/loginAction">
                用户名：<input type="text" name="userName"/>
                密码：  <input type="password" name="userPassword"/>
                <button name="submit"  type="submit">登录</button>

                <a id="forgetPassword">忘记密码</a>
                <a id="freeRegister">免费注册</a>
            </form>
        </c:otherwise>
    </c:choose>
</div>

<div class="logo">
    <label>Logo</label>
</div>
<div class="menu-top-container">
    <ul id="menu-top">
        <li class="menu-item"><a href="index" id="index">首页</a></li>
        <li class="menu-item"><a id="chartDes">图表说明</a></li>
        <li class="menu-item"><a id="selectNumber">图形选号</a></li>
        <li class="menu-item"><a id="articles">文章</a></li>
        <li class="menu-item"><a id="other">其他</a></li>
    </ul>
</div>
</body>
</html>
